#include <bits/stdc++.h>
using namespace std;
set<int64_t> S;
int64_t query(){
  int64_t l = 0, r = 0, lst = 0, ans = 0;
  auto p = S.begin(); auto q = S.rbegin(); for(; p != S.end(); p++, q++)
    l += *p, r += *q, ans += r - max(l, lst), lst = r;
  return ans;
}
int main(){
  freopen("kte.in", "r", stdin);
  freopen("kte.ans", "w", stdout);
  cin.tie(nullptr)->sync_with_stdio(false);
  int _; for(cin >> _; _--;){
    int64_t x; cin >> x; if(S.count(x)) S.erase(x); else S.insert(x);
    cout << query() << '\n';
  }
  return 0;
}
